package com.example.mvpdemo.login.presenter;

import com.example.mvpdemo.base.BasePresenter;
import com.example.mvpdemo.login.contract.LoginContract;
import com.example.mvpdemo.login.model.LoginModel;
import com.example.mvpdemo.login.view.LoginActivity;

/**
 * name 登录控制层
 * desc
 * author Sy
 * email 564379992@qq.com
 * created 2020/5/6 16:18
 */
public class LoginPresenter extends BasePresenter<LoginActivity, LoginModel, LoginContract.VP>{

    @Override
    public LoginModel getModelInstance() {
        return new LoginModel(this);
    }

    @Override
    public LoginContract.VP getContract() {
        return new LoginContract.VP() {
            @Override
            public void requestLogin(String phone, String pass) {
                try {
                    mModel.getContract().requestLogin(phone,pass);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }

            @Override
            public void responseLoginResult(boolean loginStatusResult) {
               mView.getContract().responseLoginResult(loginStatusResult);
            }
        };
    }
}
